<!DOCTYPE html><html lang="en" data-theme="light"><head><meta charset="UTF-8"><meta name="referrer" content="no-referrer"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>C#代码命名规范(一) | Welcome,Guys,Join Me for the AIminminAI Episode!</title><meta name="author" content="Hu hb"><meta name="copyright" content="Hu hb"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="@TOC  前言搞编程的，在工作中学习中，培养好的代码习惯、养成自己的一套代码风格，还是比较重要的，与诸君共勉。 一、帕斯卡命名法+驼峰命名法写代码时或者Code Review时多多参考：帕斯卡命名法&#x2F;拼写法【https:&#x2F;&#x2F;learn.microsoft.com&#x2F;zh-cn&#x2F;dotnet&#x2F;csharp&#x2F;fundamentals&#x2F;coding-style&#x2F;coding-conventio">
<meta property="og:type" content="article">
<meta property="og:title" content="C#代码命名规范(一)">
<meta property="og:url" content="https://aiminminai.gitee.io/aiminminai/2023/08/06/CommonCSharpCodeConventions-C-%E4%BB%A3%E7%A0%81%E5%91%BD%E5%90%8D%E8%A7%84%E8%8C%83%E4%B8%80/index.html">
<meta property="og:site_name" content="Welcome,Guys,Join Me for the AIminminAI Episode!">
<meta property="og:description" content="@TOC  前言搞编程的，在工作中学习中，培养好的代码习惯、养成自己的一套代码风格，还是比较重要的，与诸君共勉。 一、帕斯卡命名法+驼峰命名法写代码时或者Code Review时多多参考：帕斯卡命名法&#x2F;拼写法【https:&#x2F;&#x2F;learn.microsoft.com&#x2F;zh-cn&#x2F;dotnet&#x2F;csharp&#x2F;fundamentals&#x2F;coding-style&#x2F;coding-conventio">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://aiminminai.gitee.io/aiminminai/img/avatar.jpg">
<meta property="article:published_time" content="2023-08-06T05:46:37.000Z">
<meta property="article:modified_time" content="2023-08-12T13:03:42.524Z">
<meta property="article:author" content="Hu hb">
<meta property="article:tag" content="C#">
<meta property="article:tag" content="编程经验总结">
<meta property="article:tag" content="代码命名规范">
<meta property="article:tag" content="陷阱">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://aiminminai.gitee.io/aiminminai/img/avatar.jpg"><link rel="shortcut icon" href="/aiminminai/img/favicon.png"><link rel="canonical" href="https://aiminminai.gitee.io/aiminminai/2023/08/06/CommonCSharpCodeConventions-C-%E4%BB%A3%E7%A0%81%E5%91%BD%E5%90%8D%E8%A7%84%E8%8C%83%E4%B8%80/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//fonts.googleapis.com" crossorigin=""/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/aiminminai/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium+Web&amp;display=swap" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/aiminminai/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: 'Copy successfully',
    error: 'Copy error',
    noSupport: 'The browser does not support'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: 'days',
  dateSuffix: {
    just: 'Just',
    min: 'minutes ago',
    hour: 'hours ago',
    day: 'days ago',
    month: 'months ago'
  },
  copyright: {"limitCount":50,"languages":{"author":"Author: Hu hb","link":"Link: ","source":"Source: Welcome,Guys,Join Me for the AIminminAI Episode!","info":"Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source."}},
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: true,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'C#代码命名规范(一)',
  isPost: true,
  isHome: false,
  isHighlightShrink: true,
  isToc: true,
  postUpdate: '2023-08-12 21:03:42'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/aiminminai/img/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/aiminminai/archives/"><div class="headline">Articles</div><div class="length-num">29</div></a><a href="/aiminminai/tags/"><div class="headline">Tags</div><div class="length-num">47</div></a><a href="/aiminminai/categories/"><div class="headline">Categories</div><div class="length-num">42</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/aiminminai/"><i class="fa-fw fas fa-home"></i><span> Home(主页)</span></a></div><div class="menus_item"><a class="site-page" href="/aiminminai/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives(那些年的知识归档)</span></a></div><div class="menus_item"><a class="site-page" href="/aiminminai/tags/"><i class="fa-fw fas fa-tags"></i><span> Tags(那些年的知识标签)</span></a></div><div class="menus_item"><a class="site-page" href="/aiminminai/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories(那些年的工作经验)</span></a></div><div class="menus_item"><a class="site-page" href="/aiminminai/link/"><i class="fa-fw fas fa-link"></i><span> Link(那些年的八股)</span></a></div><div class="menus_item"><a class="site-page" href="/aiminminai/game/"><i class="fa-fw fas fa-heart"></i><span> Game Area(游戏专区，学&amp;玩)</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/aiminminai/img/JingSeOne.jpg')"><nav id="nav"><span id="blog-info"><a href="/aiminminai/" title="Welcome,Guys,Join Me for the AIminminAI Episode!"><span class="site-name">Welcome,Guys,Join Me for the AIminminAI Episode!</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/aiminminai/"><i class="fa-fw fas fa-home"></i><span> Home(主页)</span></a></div><div class="menus_item"><a class="site-page" href="/aiminminai/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives(那些年的知识归档)</span></a></div><div class="menus_item"><a class="site-page" href="/aiminminai/tags/"><i class="fa-fw fas fa-tags"></i><span> Tags(那些年的知识标签)</span></a></div><div class="menus_item"><a class="site-page" href="/aiminminai/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories(那些年的工作经验)</span></a></div><div class="menus_item"><a class="site-page" href="/aiminminai/link/"><i class="fa-fw fas fa-link"></i><span> Link(那些年的八股)</span></a></div><div class="menus_item"><a class="site-page" href="/aiminminai/game/"><i class="fa-fw fas fa-heart"></i><span> Game Area(游戏专区，学&amp;玩)</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">C#代码命名规范(一)</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">Created</span><time class="post-meta-date-created" datetime="2023-08-06T05:46:37.000Z" title="Created 2023-08-06 13:46:37">2023-08-06</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">Updated</span><time class="post-meta-date-updated" datetime="2023-08-12T13:03:42.524Z" title="Updated 2023-08-12 21:03:42">2023-08-12</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/aiminminai/categories/C/">C#</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/aiminminai/categories/C/%E6%80%BB%E7%BB%93%E3%80%81%E7%BB%8F%E9%AA%8C%E3%80%81%E9%99%B7%E9%98%B1/">总结、经验、陷阱</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="C#代码命名规范(一)"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">Post View:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><p>@<a href="%E6%96%87%E7%AB%A0%E7%9B%AE%E5%BD%95">TOC</a></p>
<hr>
<h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>搞编程的，在工作中学习中，<strong>培养好的代码习惯、养成自己的一套代码风格，还是比较重要的</strong>，与诸君共勉。</p>
<h1 id="一、帕斯卡命名法-驼峰命名法"><a href="#一、帕斯卡命名法-驼峰命名法" class="headerlink" title="一、帕斯卡命名法+驼峰命名法"></a>一、帕斯卡命名法+驼峰命名法</h1><p>写代码时或者Code Review时多多参考：帕斯卡命名法&#x2F;拼写法【<a target="_blank" rel="noopener" href="https://learn.microsoft.com/zh-cn/dotnet/csharp/fundamentals/coding-style/coding-conventions%E3%80%91">https://learn.microsoft.com/zh-cn/dotnet/csharp/fundamentals/coding-style/coding-conventions】</a></p>
<h2 id="1-命名接口interface时，使用-pascal-大小写并在名称前面加上前缀-I。-这可以清楚地向使用者表明这是-interface。比如IWorkerQueue"><a href="#1-命名接口interface时，使用-pascal-大小写并在名称前面加上前缀-I。-这可以清楚地向使用者表明这是-interface。比如IWorkerQueue" class="headerlink" title="1.命名接口interface时，使用 pascal 大小写并在名称前面加上前缀 I。 这可以清楚地向使用者表明这是 interface。比如IWorkerQueue"></a>1.命名接口interface时，使用 pascal 大小写并在名称前面加上前缀 I。 这可以清楚地向使用者表明这是 interface。比如IWorkerQueue</h2><h2 id="2-使用帕斯卡大小写"><a href="#2-使用帕斯卡大小写" class="headerlink" title="2.使用帕斯卡大小写"></a>2.使用帕斯卡大小写</h2><ul>
<li>编写位置记录时，对参数使用 pascal 大小写，因为它们是记录的公共属性</li>
<li>命名类型的 public 成员（例如字段、属性、事件、方法和本地函数）时，使用 pascal 大小写</li>
<li>命名class、record、struct时，使用pascal 大小写（“PascalCasing”）</li>
</ul>
<h2 id="3-驼峰："><a href="#3-驼峰：" class="headerlink" title="3.驼峰："></a>3.驼峰：</h2><ul>
<li>命名 private 或 internal 字段时，使用驼峰式大小写（“camelCasing”），以 _ 作为前缀。</li>
<li>使用为 private 或 internal 的static 字段时  s_ 前缀</li>
<li>对于线程静态，请使用 t_  ；</li>
</ul>
<hr>
<h1 id="二、变量、方法、注释…"><a href="#二、变量、方法、注释…" class="headerlink" title="二、变量、方法、注释…"></a>二、变量、方法、注释…</h1><h2 id="1-【变量】不要把多个变量定义到一行，会降低可读性，int-x-y-z-…赋值；以及int-x-10-y-20-…；这两种写法都不建议"><a href="#1-【变量】不要把多个变量定义到一行，会降低可读性，int-x-y-z-…赋值；以及int-x-10-y-20-…；这两种写法都不建议" class="headerlink" title="1.【变量】不要把多个变量定义到一行，会降低可读性，int x,y,z,…赋值；以及int x &#x3D; 10, y &#x3D; 20, …；这两种写法都不建议"></a>1.【变量】不要把多个变量定义到一行，会降低可读性，int x,y,z,…赋值；以及int x &#x3D; 10, y &#x3D; 20, …；这两种写法都不建议</h2><h2 id="2-【方法】扩展方法中，this参数加于形参列表中的第一个形参上、这个方法必须是静态的公有的【也就是被public-static修饰的】，方法所在类的名字必须是this所在的第一个形参的数据类型大驼峰-Extension（类命名规范）"><a href="#2-【方法】扩展方法中，this参数加于形参列表中的第一个形参上、这个方法必须是静态的公有的【也就是被public-static修饰的】，方法所在类的名字必须是this所在的第一个形参的数据类型大驼峰-Extension（类命名规范）" class="headerlink" title="2.【方法】扩展方法中，this参数加于形参列表中的第一个形参上、这个方法必须是静态的公有的【也就是被public static修饰的】，方法所在类的名字必须是this所在的第一个形参的数据类型大驼峰+Extension（类命名规范）"></a>2.【方法】扩展方法中，this参数加于形参列表中的第一个形参上、这个方法必须是静态的公有的【也就是被public static修饰的】，方法所在类的名字必须是this所在的第一个形参的数据类型大驼峰+Extension（类命名规范）</h2><ul>
<li>你要扩展某个方法时，也就是某个方法你要给人家第一个形参加上this，让你有超能力原来使用不了人家现在可以使用了，那么这个方法必须是public static修饰的静态的公有的方法，这个方法所在类的名字必须是XxxExtension</li>
</ul>
<h2 id="3-net规定，如果委托是为声明某个事件做准备，那么这个委托命名为XxxEventHandler，Xxx是事件的名字"><a href="#3-net规定，如果委托是为声明某个事件做准备，那么这个委托命名为XxxEventHandler，Xxx是事件的名字" class="headerlink" title="3..net规定，如果委托是为声明某个事件做准备，那么这个委托命名为XxxEventHandler，Xxx是事件的名字"></a>3..net规定，如果委托是为声明某个事件做准备，那么这个委托命名为XxxEventHandler，Xxx是事件的名字</h2><ul>
<li>事件处理委托一般以XxxEventHandler结尾</li>
<li>触发事件的经常时一个函数，.NET一般以OnXxx命名</li>
<li>事件处理程序的参数应该和事件委托相同，比如都是sender，e。**.net规定，如果这个class是用来传递事件信息的，这个类的名字应该是你事件的名字加上EventArgs，并且应该继承EventArgs这个基类**</li>
</ul>
<h2 id="4-当没有明确引入命名空间时【C-中的using…，Java中的import导包时】，需带上System-Xxx-Xxx…去实例化等，这个跟Java中是一样的，你没有import去导包，那么就得带上全包名或者命名空间去加以区别。"><a href="#4-当没有明确引入命名空间时【C-中的using…，Java中的import导包时】，需带上System-Xxx-Xxx…去实例化等，这个跟Java中是一样的，你没有import去导包，那么就得带上全包名或者命名空间去加以区别。" class="headerlink" title="4.当没有明确引入命名空间时【C#中的using…，Java中的import导包时】，需带上System.Xxx.Xxx…去实例化等，这个跟Java中是一样的，你没有import去导包，那么就得带上全包名或者命名空间去加以区别。"></a>4.当没有明确引入命名空间时【C#中的using…，Java中的import导包时】，需带上System.Xxx.Xxx…去实例化等，这个跟Java中是一样的，你没有import去导包，那么就得带上全包名或者命名空间去加以区别。</h2><h2 id="5-一行一语句、一行一声明、方法定于与属性定义之间添加至少一个空白行"><a href="#5-一行一语句、一行一声明、方法定于与属性定义之间添加至少一个空白行" class="headerlink" title="5.一行一语句、一行一声明、方法定于与属性定义之间添加至少一个空白行"></a>5.一行一语句、一行一声明、方法定于与属性定义之间添加至少一个空白行</h2><h2 id="6-注释"><a href="#6-注释" class="headerlink" title="6.注释"></a>6.注释</h2><ul>
<li>注释放在单独的行上而不是代码行的末尾</li>
<li>注释文本以大写字母开始</li>
<li>句号结束注释文本、注释开始一空格</li>
</ul>
<hr>
<h1 id="巨人的肩膀"><a href="#巨人的肩膀" class="headerlink" title="巨人的肩膀"></a>巨人的肩膀</h1><ul>
<li><a target="_blank" rel="noopener" href="https://learn.microsoft.com/zh-cn/dotnet/csharp/fundamentals/coding-style/coding-conventions">https://learn.microsoft.com/zh-cn/dotnet/csharp/fundamentals/coding-style/coding-conventions</a></li>
<li>菜鸟教程</li>
<li>C#高级编程</li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">Author: </span><span class="post-copyright-info"><a href="https://aiminminai.gitee.io/aiminminai">Hu hb</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">Link: </span><span class="post-copyright-info"><a href="https://aiminminai.gitee.io/aiminminai/2023/08/06/CommonCSharpCodeConventions-C-%E4%BB%A3%E7%A0%81%E5%91%BD%E5%90%8D%E8%A7%84%E8%8C%83%E4%B8%80/">https://aiminminai.gitee.io/aiminminai/2023/08/06/CommonCSharpCodeConventions-C-%E4%BB%A3%E7%A0%81%E5%91%BD%E5%90%8D%E8%A7%84%E8%8C%83%E4%B8%80/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">Copyright Notice: </span><span class="post-copyright-info">All articles in this blog are licensed under <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> unless stating additionally.</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/aiminminai/tags/C/">C#</a><a class="post-meta__tags" href="/aiminminai/tags/%E7%BC%96%E7%A8%8B%E7%BB%8F%E9%AA%8C%E6%80%BB%E7%BB%93/">编程经验总结</a><a class="post-meta__tags" href="/aiminminai/tags/%E4%BB%A3%E7%A0%81%E5%91%BD%E5%90%8D%E8%A7%84%E8%8C%83/">代码命名规范</a><a class="post-meta__tags" href="/aiminminai/tags/%E9%99%B7%E9%98%B1/">陷阱</a></div><div class="post_share"><div class="social-share" data-image="/aiminminai/img/avatar.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> Donate</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/aiminminai/img/WeChat.jpg" target="_blank"><img class="post-qr-code-img" src="/aiminminai/img/WeChat.jpg" alt="wechat"/></a><div class="post-qr-code-desc">wechat</div></li><li class="reward-item"><a href="/aiminminai/img/Alipay.jpg" target="_blank"><img class="post-qr-code-img" src="/aiminminai/img/Alipay.jpg" alt="alipay"/></a><div class="post-qr-code-desc">alipay</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-full"><a href="/aiminminai/2023/08/12/C-%E7%BC%96%E7%A8%8B%E7%BB%8F%E9%AA%8C-%E9%81%87%E5%88%B0%E7%9A%84bug%E5%8F%8A%E9%99%B7%E9%98%B1-%E4%B8%80/" title="C#编程经验/遇到陷阱总结(一)"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">Previous Post</div><div class="prev_info">C#编程经验/遇到陷阱总结(一)</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>Related Articles</span></div><div class="relatedPosts-list"><div><a href="/aiminminai/2023/08/12/C-%E7%BC%96%E7%A8%8B%E7%BB%8F%E9%AA%8C-%E9%81%87%E5%88%B0%E7%9A%84bug%E5%8F%8A%E9%99%B7%E9%98%B1-%E4%B8%80/" title="C#编程经验&#x2F;遇到陷阱总结(一)"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-08-12</div><div class="title">C#编程经验&#x2F;遇到陷阱总结(一)</div></div></a></div><div><a href="/aiminminai/2023/08/20/C-%E7%BC%96%E7%A8%8B%E7%BB%8F%E9%AA%8C-%E9%81%87%E5%88%B0%E9%99%B7%E9%98%B1%E6%80%BB%E7%BB%93-%E4%B8%89/" title="C#编程经验&#x2F;遇到陷阱总结(三)"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-08-20</div><div class="title">C#编程经验&#x2F;遇到陷阱总结(三)</div></div></a></div><div><a href="/aiminminai/2023/08/20/C-%E7%BC%96%E7%A8%8B%E7%BB%8F%E9%AA%8C-%E9%81%87%E5%88%B0%E9%99%B7%E9%98%B1%E6%80%BB%E7%BB%93-%E4%BA%8C/" title="C#编程经验&#x2F;遇到陷阱总结(二)"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-08-20</div><div class="title">C#编程经验&#x2F;遇到陷阱总结(二)</div></div></a></div><div><a href="/aiminminai/2023/08/31/C-%E7%BC%96%E7%A8%8B%E7%BB%8F%E9%AA%8C-%E9%81%87%E5%88%B0%E7%9A%84bug%E5%8F%8A%E9%99%B7%E9%98%B1-%E5%9B%9B/" title="C-编程经验-遇到的bug及陷阱-四"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-08-31</div><div class="title">C-编程经验-遇到的bug及陷阱-四</div></div></a></div><div><a href="/aiminminai/2023/08/21/C-%E9%AB%98%E9%A2%91%E8%AF%AD%E6%B3%95%E9%9B%86%E9%94%A6-%E4%B8%80/" title="C#高频语法集锦(一)"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-08-21</div><div class="title">C#高频语法集锦(一)</div></div></a></div><div><a href="/aiminminai/2023/08/30/C-%E9%AB%98%E9%A2%91%E8%AF%AD%E6%B3%95%E9%9B%86%E9%94%A6-%E4%BA%8C/" title="C#高频语法集锦(二)"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-08-30</div><div class="title">C#高频语法集锦(二)</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/aiminminai/img/avatar.jpg" onerror="this.onerror=null;this.src='/aiminminai/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Hu hb</div><div class="author-info__description">寻寻觅觅，原来未来的你，在这里呀</div></div><div class="card-info-data site-data is-center"><a href="/aiminminai/archives/"><div class="headline">Articles</div><div class="length-num">29</div></a><a href="/aiminminai/tags/"><div class="headline">Tags</div><div class="length-num">47</div></a><a href="/aiminminai/categories/"><div class="headline">Categories</div><div class="length-num">42</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/aiminminai"><i class="Gitee"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="mailto:min221forever@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://github.com/YWMHHBAIminminAI" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="https://blog.csdn.net/m0_52436398?type=blog" target="_blank" title="CSDN"><i class="fa fa-book-open"></i></a><a class="social-icon" href="https://gitee.com/aiminminai" target="_blank" title="Gitee"><i class="fa fa-g"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>Announcement</span></div><div class="announcement_content"><b><font color="#e66b6d">掬</font> <font color="#e66d98">水</font> <font color="#e66cc6">月</font> <font color="#cc6de6">在</font> <font        color="#9770e6">手</font> <font color="#6d93e6">，</font> <font color="#6fcde6">弄</font> <font color="#72e6b6">花</font> <font color="#72e689">香</font> <font color="#99e670">满</font> <font color="#cde670">衣</font> <p align="center"><img src="https://haiyong.site/img/img-blog.csdnimg.cn/f7384c88956d4378b72e47548e19c9f8.gif" width="50" alt="mao"></p> <p align="center">微信号：phone_15902953075</p> <p align="center">QQ号：1317957931</p></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>Catalog</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%89%8D%E8%A8%80"><span class="toc-number">1.</span> <span class="toc-text">前言</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%80%E3%80%81%E5%B8%95%E6%96%AF%E5%8D%A1%E5%91%BD%E5%90%8D%E6%B3%95-%E9%A9%BC%E5%B3%B0%E5%91%BD%E5%90%8D%E6%B3%95"><span class="toc-number">2.</span> <span class="toc-text">一、帕斯卡命名法+驼峰命名法</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E5%91%BD%E5%90%8D%E6%8E%A5%E5%8F%A3interface%E6%97%B6%EF%BC%8C%E4%BD%BF%E7%94%A8-pascal-%E5%A4%A7%E5%B0%8F%E5%86%99%E5%B9%B6%E5%9C%A8%E5%90%8D%E7%A7%B0%E5%89%8D%E9%9D%A2%E5%8A%A0%E4%B8%8A%E5%89%8D%E7%BC%80-I%E3%80%82-%E8%BF%99%E5%8F%AF%E4%BB%A5%E6%B8%85%E6%A5%9A%E5%9C%B0%E5%90%91%E4%BD%BF%E7%94%A8%E8%80%85%E8%A1%A8%E6%98%8E%E8%BF%99%E6%98%AF-interface%E3%80%82%E6%AF%94%E5%A6%82IWorkerQueue"><span class="toc-number">2.1.</span> <span class="toc-text">1.命名接口interface时，使用 pascal 大小写并在名称前面加上前缀 I。 这可以清楚地向使用者表明这是 interface。比如IWorkerQueue</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E4%BD%BF%E7%94%A8%E5%B8%95%E6%96%AF%E5%8D%A1%E5%A4%A7%E5%B0%8F%E5%86%99"><span class="toc-number">2.2.</span> <span class="toc-text">2.使用帕斯卡大小写</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-%E9%A9%BC%E5%B3%B0%EF%BC%9A"><span class="toc-number">2.3.</span> <span class="toc-text">3.驼峰：</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BA%8C%E3%80%81%E5%8F%98%E9%87%8F%E3%80%81%E6%96%B9%E6%B3%95%E3%80%81%E6%B3%A8%E9%87%8A%E2%80%A6"><span class="toc-number">3.</span> <span class="toc-text">二、变量、方法、注释…</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E3%80%90%E5%8F%98%E9%87%8F%E3%80%91%E4%B8%8D%E8%A6%81%E6%8A%8A%E5%A4%9A%E4%B8%AA%E5%8F%98%E9%87%8F%E5%AE%9A%E4%B9%89%E5%88%B0%E4%B8%80%E8%A1%8C%EF%BC%8C%E4%BC%9A%E9%99%8D%E4%BD%8E%E5%8F%AF%E8%AF%BB%E6%80%A7%EF%BC%8Cint-x-y-z-%E2%80%A6%E8%B5%8B%E5%80%BC%EF%BC%9B%E4%BB%A5%E5%8F%8Aint-x-10-y-20-%E2%80%A6%EF%BC%9B%E8%BF%99%E4%B8%A4%E7%A7%8D%E5%86%99%E6%B3%95%E9%83%BD%E4%B8%8D%E5%BB%BA%E8%AE%AE"><span class="toc-number">3.1.</span> <span class="toc-text">1.【变量】不要把多个变量定义到一行，会降低可读性，int x,y,z,…赋值；以及int x &#x3D; 10, y &#x3D; 20, …；这两种写法都不建议</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E3%80%90%E6%96%B9%E6%B3%95%E3%80%91%E6%89%A9%E5%B1%95%E6%96%B9%E6%B3%95%E4%B8%AD%EF%BC%8Cthis%E5%8F%82%E6%95%B0%E5%8A%A0%E4%BA%8E%E5%BD%A2%E5%8F%82%E5%88%97%E8%A1%A8%E4%B8%AD%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%BD%A2%E5%8F%82%E4%B8%8A%E3%80%81%E8%BF%99%E4%B8%AA%E6%96%B9%E6%B3%95%E5%BF%85%E9%A1%BB%E6%98%AF%E9%9D%99%E6%80%81%E7%9A%84%E5%85%AC%E6%9C%89%E7%9A%84%E3%80%90%E4%B9%9F%E5%B0%B1%E6%98%AF%E8%A2%ABpublic-static%E4%BF%AE%E9%A5%B0%E7%9A%84%E3%80%91%EF%BC%8C%E6%96%B9%E6%B3%95%E6%89%80%E5%9C%A8%E7%B1%BB%E7%9A%84%E5%90%8D%E5%AD%97%E5%BF%85%E9%A1%BB%E6%98%AFthis%E6%89%80%E5%9C%A8%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%BD%A2%E5%8F%82%E7%9A%84%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E5%A4%A7%E9%A9%BC%E5%B3%B0-Extension%EF%BC%88%E7%B1%BB%E5%91%BD%E5%90%8D%E8%A7%84%E8%8C%83%EF%BC%89"><span class="toc-number">3.2.</span> <span class="toc-text">2.【方法】扩展方法中，this参数加于形参列表中的第一个形参上、这个方法必须是静态的公有的【也就是被public static修饰的】，方法所在类的名字必须是this所在的第一个形参的数据类型大驼峰+Extension（类命名规范）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-net%E8%A7%84%E5%AE%9A%EF%BC%8C%E5%A6%82%E6%9E%9C%E5%A7%94%E6%89%98%E6%98%AF%E4%B8%BA%E5%A3%B0%E6%98%8E%E6%9F%90%E4%B8%AA%E4%BA%8B%E4%BB%B6%E5%81%9A%E5%87%86%E5%A4%87%EF%BC%8C%E9%82%A3%E4%B9%88%E8%BF%99%E4%B8%AA%E5%A7%94%E6%89%98%E5%91%BD%E5%90%8D%E4%B8%BAXxxEventHandler%EF%BC%8CXxx%E6%98%AF%E4%BA%8B%E4%BB%B6%E7%9A%84%E5%90%8D%E5%AD%97"><span class="toc-number">3.3.</span> <span class="toc-text">3..net规定，如果委托是为声明某个事件做准备，那么这个委托命名为XxxEventHandler，Xxx是事件的名字</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-%E5%BD%93%E6%B2%A1%E6%9C%89%E6%98%8E%E7%A1%AE%E5%BC%95%E5%85%A5%E5%91%BD%E5%90%8D%E7%A9%BA%E9%97%B4%E6%97%B6%E3%80%90C-%E4%B8%AD%E7%9A%84using%E2%80%A6%EF%BC%8CJava%E4%B8%AD%E7%9A%84import%E5%AF%BC%E5%8C%85%E6%97%B6%E3%80%91%EF%BC%8C%E9%9C%80%E5%B8%A6%E4%B8%8ASystem-Xxx-Xxx%E2%80%A6%E5%8E%BB%E5%AE%9E%E4%BE%8B%E5%8C%96%E7%AD%89%EF%BC%8C%E8%BF%99%E4%B8%AA%E8%B7%9FJava%E4%B8%AD%E6%98%AF%E4%B8%80%E6%A0%B7%E7%9A%84%EF%BC%8C%E4%BD%A0%E6%B2%A1%E6%9C%89import%E5%8E%BB%E5%AF%BC%E5%8C%85%EF%BC%8C%E9%82%A3%E4%B9%88%E5%B0%B1%E5%BE%97%E5%B8%A6%E4%B8%8A%E5%85%A8%E5%8C%85%E5%90%8D%E6%88%96%E8%80%85%E5%91%BD%E5%90%8D%E7%A9%BA%E9%97%B4%E5%8E%BB%E5%8A%A0%E4%BB%A5%E5%8C%BA%E5%88%AB%E3%80%82"><span class="toc-number">3.4.</span> <span class="toc-text">4.当没有明确引入命名空间时【C#中的using…，Java中的import导包时】，需带上System.Xxx.Xxx…去实例化等，这个跟Java中是一样的，你没有import去导包，那么就得带上全包名或者命名空间去加以区别。</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-%E4%B8%80%E8%A1%8C%E4%B8%80%E8%AF%AD%E5%8F%A5%E3%80%81%E4%B8%80%E8%A1%8C%E4%B8%80%E5%A3%B0%E6%98%8E%E3%80%81%E6%96%B9%E6%B3%95%E5%AE%9A%E4%BA%8E%E4%B8%8E%E5%B1%9E%E6%80%A7%E5%AE%9A%E4%B9%89%E4%B9%8B%E9%97%B4%E6%B7%BB%E5%8A%A0%E8%87%B3%E5%B0%91%E4%B8%80%E4%B8%AA%E7%A9%BA%E7%99%BD%E8%A1%8C"><span class="toc-number">3.5.</span> <span class="toc-text">5.一行一语句、一行一声明、方法定于与属性定义之间添加至少一个空白行</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6-%E6%B3%A8%E9%87%8A"><span class="toc-number">3.6.</span> <span class="toc-text">6.注释</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%B7%A8%E4%BA%BA%E7%9A%84%E8%82%A9%E8%86%80"><span class="toc-number">4.</span> <span class="toc-text">巨人的肩膀</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>Recent Post</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/aiminminai/2024/03/28/%E9%A1%B9%E7%9B%AE%E5%BC%80%E5%8F%91%E6%80%BB%E7%BB%93%E4%B9%8BC-%E5%86%99%E4%BA%86%E4%B8%80%E4%B8%AA%E4%B8%8A%E4%BD%8D%E6%9C%BA%E9%A1%B5%E9%9D%A2%EF%BC%8C%E8%BD%AF%E4%BB%B6%E5%8D%A1%E6%AD%BB%E4%BA%86%EF%BC%9F%EF%BC%9F%EF%BC%9F/" title="项目开发总结之C#写了一个上位机页面，软件卡死了？？？">项目开发总结之C#写了一个上位机页面，软件卡死了？？？</a><time datetime="2024-03-28T15:41:40.000Z" title="Created 2024-03-28 23:41:40">2024-03-28</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/aiminminai/2024/03/27/Golang-web-http%E6%A1%86%E6%9E%B6/" title="Golang-web/http框架">Golang-web/http框架</a><time datetime="2024-03-27T15:27:12.000Z" title="Created 2024-03-27 23:27:12">2024-03-27</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/aiminminai/2024/03/24/Golang-%E7%BB%83%E5%9F%BA%E6%9C%AC%E5%8A%9F%EF%BC%9A%E6%89%8E%E9%A9%AC%E6%AD%A5%E3%80%81%E7%BB%83%E6%8A%95%E7%AF%AE/" title="Golang-练基本功：扎马步、练投篮、练运球">Golang-练基本功：扎马步、练投篮、练运球</a><time datetime="2024-03-24T15:42:23.000Z" title="Created 2024-03-24 23:42:23">2024-03-24</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/aiminminai/2024/03/15/%E8%83%BD%E4%B8%8D%E8%83%BD%E7%BB%99%E5%88%AB%E4%BA%BA%E4%B8%80%E4%B8%AA%E4%B8%8A%E6%89%8B%E5%B0%B1%E8%83%BD%E7%9C%8B%E6%87%82%E5%B0%B1%E8%83%BD%E7%94%A8%E7%9A%84%E4%B8%89%E5%B1%82%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C%EF%BC%88%E4%BB%A3%E7%A0%81%EF%BC%89%E6%A8%A1%E5%9E%8B%E5%91%A2%EF%BC%9F/" title="能不能给别人一个上手就能看懂就能用的三层神经网络（代码）模型呢？">能不能给别人一个上手就能看懂就能用的三层神经网络（代码）模型呢？</a><time datetime="2024-03-14T16:23:21.000Z" title="Created 2024-03-15 00:23:21">2024-03-15</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/aiminminai/2024/02/28/%E6%89%93%E7%A0%B4%E7%A0%82%E9%94%85%E9%97%AE-WPF%E5%8E%9F%E7%90%86-03-WPF%E6%A0%B7%E5%BC%8F%E8%AE%BE%E7%BD%AE%E5%92%8C%E6%A8%A1%E6%9D%BF%E5%8C%96%E3%80%81%E5%86%85%E8%81%94%E6%A0%B7%E5%BC%8F%E5%92%8C%E6%A8%A1%E6%9D%BF/" title="打破砂锅问-WPF原理-03-WPF样式设置和模板化、内联样式和模板">打破砂锅问-WPF原理-03-WPF样式设置和模板化、内联样式和模板</a><time datetime="2024-02-28T15:10:28.000Z" title="Created 2024-02-28 23:10:28">2024-02-28</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2024 By Hu hb</div><div class="framework-info"><span>Framework </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>Theme </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="Read Mode"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="Switch Between Light And Dark Mode"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="Toggle between single-column and double-column"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="Setting"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="Table Of Contents"><i class="fas fa-list-ul"></i></button><button id="chat-btn" type="button" title="Chat"><i class="fas fa-sms"></i></button><button id="go-up" type="button" title="Back To Top"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/aiminminai/js/utils.js"></script><script src="/aiminminai/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-nest.min.js"></script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/click-heart.min.js" async="async" mobile="false"></script><script>(() => {
  const isChatBtn = true
  const isChatHideShow = true

  if (isChatBtn) {
    const close = () => {
      Chatra('minimizeWidget')
      Chatra('hide')
    }

    const open = () => {
      Chatra('openChat', true)
      Chatra('show')
    }

    window.ChatraSetup = {
      startHidden: true
    }
  
    window.chatBtnFn = () => {
      const isShow = document.getElementById('chatra').classList.contains('chatra--expanded')
      isShow ? close() : open()
    }
  } else if (isChatHideShow) {
    window.chatBtn = {
      hide: () => {
        Chatra('hide')
      },
      show: () => {
        Chatra('show')
      }
    }
  }

  (function(d, w, c) {
    w.ChatraID = 't3Zijv5iKg5Z5HT6v'
    var s = d.createElement('script')
    w[c] = w[c] || function() {
        (w[c].q = w[c].q || []).push(arguments)
    }
    s.async = true
    s.src = 'https://call.chatra.io/chatra.js'
    if (d.head) d.head.appendChild(s)
  })(document, window, 'Chatra')

})()</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>